package com.wgod.security.admin.rest;

import com.wgod.security.admin.biz.PersonService;
import com.wgod.security.admin.entity.PersonEntity;
import com.wgod.security.admin.feign.ITestService;
import com.wgod.security.common.msg.TableResultResponse;
import com.wgod.security.common.rest.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * ${DESCRIPTION}
 *
 * @author WGod
 * @create 2017-06-08 11:51
 */
@RestController
@RequestMapping("persons")
public class PersonController extends BaseController<PersonService,PersonEntity> {

    @Autowired
    @Lazy
    private ITestService testService;

    @RequestMapping(value = "/test", method = RequestMethod.GET)
    public @ResponseBody
    String test() throws Exception {
        return testService.test("----从demo过来的----");
    }

    @RequestMapping("list")
    @ResponseBody
    public TableResultResponse<PersonEntity> page(@RequestParam(defaultValue = "10") int limit, @RequestParam(defaultValue = "1") int offset) {

        List<PersonEntity> persons = baseService.selectListAll();
        return new TableResultResponse<PersonEntity>(persons.size(), persons);
    }

}
